Fix "request methods will accept only keyword arguments" deprecation

Dominik Sander 7 years ago
parent
commit
03b628dadb

+ 6 - 6
spec/controllers/admin/users_controller_spec.rb

@@ -6,8 +6,8 @@ describe Admin::UsersController do
6 6
       it 'imports the default scenario for the new user' do
7 7
         mock(DefaultScenarioImporter).import(is_a(User))
8 8
         sign_in users(:jane)
9
-        post :create, :user => {username: 'jdoe', email: 'jdoe@example.com',
10
-                             password: 's3cr3t55', password_confirmation: 's3cr3t55', admin: false }
9
+        post :create, params: {:user => {username: 'jdoe', email: 'jdoe@example.com',
10
+                                         password: 's3cr3t55', password_confirmation: 's3cr3t55', admin: false }}
11 11
       end
12 12
     end
13 13
     
@@ -15,7 +15,7 @@ describe Admin::UsersController do
15 15
       it 'does not import the default scenario' do
16 16
         stub(DefaultScenarioImporter).import(is_a(User)) { fail "Should not attempt import" }
17 17
         sign_in users(:jane)
18
-        post :create, :user => {username: 'user'}
18
+        post :create, params: {:user => {username: 'user'}}
19 19
       end
20 20
     end
21 21
   end
@@ -24,7 +24,7 @@ describe Admin::UsersController do
24 24
     it "switches to another user" do
25 25
       sign_in users(:jane)
26 26
 
27
-      get :switch_to_user, :id => users(:bob).id
27
+      get :switch_to_user, params: {:id => users(:bob).id}
28 28
       expect(response).to redirect_to(agents_path)
29 29
       expect(subject.session[:original_admin_user_id]).to eq(users(:jane).id)
30 30
     end
@@ -32,7 +32,7 @@ describe Admin::UsersController do
32 32
     it "does not switch if not admin" do
33 33
       sign_in users(:bob)
34 34
 
35
-      get :switch_to_user, :id => users(:jane).id
35
+      get :switch_to_user, params: {:id => users(:jane).id}
36 36
       expect(response).to redirect_to(root_path)
37 37
     end
38 38
   end
@@ -41,7 +41,7 @@ describe Admin::UsersController do
41 41
     it "switches to another user and back" do
42 42
       sign_in users(:jane)
43 43
 
44
-      get :switch_to_user, :id => users(:bob).id
44
+      get :switch_to_user, params: {:id => users(:bob).id}
45 45
       expect(response).to redirect_to(agents_path)
46 46
       expect(subject.session[:original_admin_user_id]).to eq(users(:jane).id)
47 47
 

+ 9 - 9
spec/controllers/agents/dry_runs_controller_spec.rb

@@ -16,7 +16,7 @@ describe Agents::DryRunsController do
16 16
 
17 17
   describe "GET index" do
18 18
     it "does not load any events without specifing sources" do
19
-      get :index, type: 'Agents::WebsiteAgent', source_ids: []
19
+      get :index, params: {type: 'Agents::WebsiteAgent', source_ids: []}
20 20
       expect(assigns(:events)).to eq([])
21 21
     end
22 22
 
@@ -29,13 +29,13 @@ describe Agents::DryRunsController do
29 29
       end
30 30
 
31 31
       it "for new agents" do
32
-        get :index, type: 'Agents::WebsiteAgent', source_ids: [@agent.id]
32
+        get :index, params: {type: 'Agents::WebsiteAgent', source_ids: [@agent.id]}
33 33
         expect(assigns(:events)).to eq([])
34 34
       end
35 35
 
36 36
       it "for existing agents" do
37 37
         expect(@agent.events.count).not_to be(0)
38
-        expect { get :index, agent_id: @agent }.to raise_error(NoMethodError)
38
+        expect { get :index, params: {agent_id: @agent} }.to raise_error(NoMethodError)
39 39
       end
40 40
     end
41 41
 
@@ -47,12 +47,12 @@ describe Agents::DryRunsController do
47 47
       end
48 48
 
49 49
       it "load the most recent events when providing source ids" do
50
-        get :index, type: 'Agents::WebsiteAgent', source_ids: [@agent.id]
50
+        get :index, params: {type: 'Agents::WebsiteAgent', source_ids: [@agent.id]}
51 51
         expect(assigns(:events)).to eq([@agent.events.first])
52 52
       end
53 53
 
54 54
       it "loads the most recent events for a saved agent" do
55
-        get :index, agent_id: @agent
55
+        get :index, params: {agent_id: @agent}
56 56
         expect(assigns(:events)).to eq([@agent.events.first])
57 57
       end
58 58
     end
@@ -65,7 +65,7 @@ describe Agents::DryRunsController do
65 65
 
66 66
     it "does not actually create any agent, event or log" do
67 67
       expect {
68
-        post :create, agent: valid_attributes
68
+        post :create, params: {agent: valid_attributes}
69 69
       }.not_to change {
70 70
         [users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count]
71 71
       }
@@ -81,7 +81,7 @@ describe Agents::DryRunsController do
81 81
     it "does not actually update an agent" do
82 82
       agent = agents(:bob_weather_agent)
83 83
       expect {
84
-        post :create, agent_id: agent, agent: valid_attributes(name: 'New Name')
84
+        post :create, params: {agent_id: agent, agent: valid_attributes(name: 'New Name')}
85 85
       }.not_to change {
86 86
         [users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count, agent.name, agent.updated_at]
87 87
       }
@@ -93,7 +93,7 @@ describe Agents::DryRunsController do
93 93
       agent.save!
94 94
       url_from_event = "http://xkcd.com/?from_event=1".freeze
95 95
       expect {
96
-        post :create, agent_id: agent, event: { url: url_from_event }
96
+        post :create, params: {agent_id: agent, event: { url: url_from_event }}
97 97
       }.not_to change {
98 98
         [users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count, agent.name, agent.updated_at]
99 99
       }
@@ -112,7 +112,7 @@ describe Agents::DryRunsController do
112 112
       agent.memory = {fu: "bar"}
113 113
       agent.user = users(:bob)
114 114
       agent.save!
115
-      post :create, agent_id: agent, agent: valid_params
115
+      post :create, params: {agent_id: agent, agent: valid_params}
116 116
       results = assigns(:results)
117 117
       expect(results[:events][0]).to eql({"message" => "bar"})
118 118
     end

+ 48 - 48
spec/controllers/agents_controller_spec.rb

@@ -29,7 +29,7 @@ describe AgentsController do
29 29
   describe "POST handle_details_post" do
30 30
     it "passes control to handle_details_post on the agent" do
31 31
       sign_in users(:bob)
32
-      post :handle_details_post, :id => agents(:bob_manual_event_agent).to_param, :payload => { :foo => "bar" }.to_json
32
+      post :handle_details_post, params: {:id => agents(:bob_manual_event_agent).to_param, :payload => { :foo => "bar" }.to_json}
33 33
       expect(JSON.parse(response.body)).to eq({ "success" => true })
34 34
       expect(agents(:bob_manual_event_agent).events.last.payload).to eq({ 'foo' => "bar" })
35 35
     end
@@ -37,7 +37,7 @@ describe AgentsController do
37 37
     it "can only be accessed by the Agent's owner" do
38 38
       sign_in users(:jane)
39 39
       expect {
40
-        post :handle_details_post, :id => agents(:bob_manual_event_agent).to_param, :payload => { :foo => :bar }.to_json
40
+        post :handle_details_post, params: {:id => agents(:bob_manual_event_agent).to_param, :payload => { :foo => :bar }.to_json}
41 41
       }.to raise_error(ActiveRecord::RecordNotFound)
42 42
     end
43 43
   end
@@ -46,13 +46,13 @@ describe AgentsController do
46 46
     it "triggers Agent.async_check with the Agent's ID" do
47 47
       sign_in users(:bob)
48 48
       mock(Agent).async_check(agents(:bob_manual_event_agent).id)
49
-      post :run, :id => agents(:bob_manual_event_agent).to_param
49
+      post :run, params: {:id => agents(:bob_manual_event_agent).to_param}
50 50
     end
51 51
 
52 52
     it "can only be accessed by the Agent's owner" do
53 53
       sign_in users(:jane)
54 54
       expect {
55
-        post :run, :id => agents(:bob_manual_event_agent).to_param
55
+        post :run, params: {:id => agents(:bob_manual_event_agent).to_param}
56 56
       }.to raise_error(ActiveRecord::RecordNotFound)
57 57
     end
58 58
   end
@@ -62,7 +62,7 @@ describe AgentsController do
62 62
       sign_in users(:bob)
63 63
       agent_event = events(:bob_website_agent_event).id
64 64
       other_event = events(:jane_website_agent_event).id
65
-      post :remove_events, :id => agents(:bob_website_agent).to_param
65
+      post :remove_events, params: {:id => agents(:bob_website_agent).to_param}
66 66
       expect(Event.where(:id => agent_event).count).to eq(0)
67 67
       expect(Event.where(:id => other_event).count).to eq(1)
68 68
     end
@@ -70,7 +70,7 @@ describe AgentsController do
70 70
     it "can only be accessed by the Agent's owner" do
71 71
       sign_in users(:jane)
72 72
       expect {
73
-        post :remove_events, :id => agents(:bob_website_agent).to_param
73
+        post :remove_events, params: {:id => agents(:bob_website_agent).to_param}
74 74
       }.to raise_error(ActiveRecord::RecordNotFound)
75 75
     end
76 76
   end
@@ -110,11 +110,11 @@ describe AgentsController do
110 110
   describe "GET show" do
111 111
     it "only shows Agents for the current user" do
112 112
       sign_in users(:bob)
113
-      get :show, :id => agents(:bob_website_agent).to_param
113
+      get :show, params: {:id => agents(:bob_website_agent).to_param}
114 114
       expect(assigns(:agent)).to eq(agents(:bob_website_agent))
115 115
 
116 116
       expect {
117
-        get :show, :id => agents(:jane_website_agent).to_param
117
+        get :show, params: {:id => agents(:jane_website_agent).to_param}
118 118
       }.to raise_error(ActiveRecord::RecordNotFound)
119 119
     end
120 120
   end
@@ -123,7 +123,7 @@ describe AgentsController do
123 123
     describe "with :id" do
124 124
       it "opens a clone of a given Agent" do
125 125
         sign_in users(:bob)
126
-        get :new, :id => agents(:bob_website_agent).to_param
126
+        get :new, params: {:id => agents(:bob_website_agent).to_param}
127 127
         expect(assigns(:agent).attributes).to eq(users(:bob).agents.build_clone(agents(:bob_website_agent)).attributes)
128 128
       end
129 129
 
@@ -131,7 +131,7 @@ describe AgentsController do
131 131
         sign_in users(:bob)
132 132
 
133 133
         expect {
134
-          get :new, :id => agents(:jane_website_agent).to_param
134
+          get :new, params: {:id => agents(:jane_website_agent).to_param}
135 135
         }.to raise_error(ActiveRecord::RecordNotFound)
136 136
       end
137 137
     end
@@ -139,13 +139,13 @@ describe AgentsController do
139 139
     describe "with a scenario_id" do
140 140
       it 'populates the assigned agent with the scenario' do
141 141
         sign_in users(:bob)
142
-        get :new, :scenario_id => scenarios(:bob_weather).id
142
+        get :new, params: {:scenario_id => scenarios(:bob_weather).id}
143 143
         expect(assigns(:agent).scenario_ids).to eq([scenarios(:bob_weather).id])
144 144
       end
145 145
 
146 146
       it "does not see other user's scenarios" do
147 147
         sign_in users(:bob)
148
-        get :new, :scenario_id => scenarios(:jane_weather).id
148
+        get :new, params: {:scenario_id => scenarios(:jane_weather).id}
149 149
         expect(assigns(:agent).scenario_ids).to eq([])
150 150
       end
151 151
     end
@@ -154,11 +154,11 @@ describe AgentsController do
154 154
   describe "GET edit" do
155 155
     it "only shows Agents for the current user" do
156 156
       sign_in users(:bob)
157
-      get :edit, :id => agents(:bob_website_agent).to_param
157
+      get :edit, params: {:id => agents(:bob_website_agent).to_param}
158 158
       expect(assigns(:agent)).to eq(agents(:bob_website_agent))
159 159
 
160 160
       expect {
161
-        get :edit, :id => agents(:jane_website_agent).to_param
161
+        get :edit, params: {:id => agents(:jane_website_agent).to_param}
162 162
       }.to raise_error(ActiveRecord::RecordNotFound)
163 163
     end
164 164
   end
@@ -167,27 +167,27 @@ describe AgentsController do
167 167
     it "errors on bad types" do
168 168
       sign_in users(:bob)
169 169
       expect {
170
-        post :create, :agent => valid_attributes(:type => "Agents::ThisIsFake")
170
+        post :create, params: {:agent => valid_attributes(:type => "Agents::ThisIsFake")}
171 171
       }.not_to change { users(:bob).agents.count }
172 172
       expect(assigns(:agent)).to be_a(Agent)
173 173
       expect(assigns(:agent)).to have(1).error_on(:type)
174 174
 
175 175
       sign_in users(:bob)
176 176
       expect {
177
-        post :create, :agent => valid_attributes(:type => "Object")
177
+        post :create, params: {:agent => valid_attributes(:type => "Object")}
178 178
       }.not_to change { users(:bob).agents.count }
179 179
       expect(assigns(:agent)).to be_a(Agent)
180 180
       expect(assigns(:agent)).to have(1).error_on(:type)
181 181
       sign_in users(:bob)
182 182
 
183 183
       expect {
184
-        post :create, :agent => valid_attributes(:type => "Agent")
184
+        post :create, params: {:agent => valid_attributes(:type => "Agent")}
185 185
       }.not_to change { users(:bob).agents.count }
186 186
       expect(assigns(:agent)).to be_a(Agent)
187 187
       expect(assigns(:agent)).to have(1).error_on(:type)
188 188
 
189 189
       expect {
190
-        post :create, :agent => valid_attributes(:type => "User")
190
+        post :create, params: {:agent => valid_attributes(:type => "User")}
191 191
       }.not_to change { users(:bob).agents.count }
192 192
       expect(assigns(:agent)).to be_a(Agent)
193 193
       expect(assigns(:agent)).to have(1).error_on(:type)
@@ -197,7 +197,7 @@ describe AgentsController do
197 197
       sign_in users(:bob)
198 198
       expect {
199 199
         expect {
200
-          post :create, :agent => valid_attributes
200
+          post :create, params: {:agent => valid_attributes}
201 201
         }.to change { users(:bob).agents.count }.by(1)
202 202
       }.to change { Link.count }.by(1)
203 203
       expect(assigns(:agent)).to be_a(Agents::WebsiteAgent)
@@ -209,7 +209,7 @@ describe AgentsController do
209 209
       attributes[:receiver_ids] = attributes[:source_ids]
210 210
       expect {
211 211
         expect {
212
-          post :create, :agent => attributes
212
+          post :create, params: {:agent => attributes}
213 213
         }.to change { users(:bob).agents.count }.by(1)
214 214
       }.to change { Link.count }.by(2)
215 215
       expect(assigns(:agent)).to be_a(Agents::WebsiteAgent)
@@ -218,7 +218,7 @@ describe AgentsController do
218 218
     it "shows errors" do
219 219
       sign_in users(:bob)
220 220
       expect {
221
-        post :create, :agent => valid_attributes(:name => "")
221
+        post :create, params: {:agent => valid_attributes(:name => "")}
222 222
       }.not_to change { users(:bob).agents.count }
223 223
       expect(assigns(:agent)).to have(1).errors_on(:name)
224 224
       expect(response).to render_template("new")
@@ -228,7 +228,7 @@ describe AgentsController do
228 228
       sign_in users(:bob)
229 229
       expect {
230 230
         expect {
231
-          post :create, :agent => valid_attributes(:source_ids => [agents(:jane_weather_agent).id])
231
+          post :create, params: {:agent => valid_attributes(:source_ids => [agents(:jane_weather_agent).id])}
232 232
         }.not_to change { users(:bob).agents.count }
233 233
       }.not_to change { Link.count }
234 234
     end
@@ -237,25 +237,25 @@ describe AgentsController do
237 237
   describe "PUT update" do
238 238
     it "does not allow changing types" do
239 239
       sign_in users(:bob)
240
-      post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:type => "Agents::WeatherAgent")
240
+      post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:type => "Agents::WeatherAgent")}
241 241
       expect(assigns(:agent)).to have(1).errors_on(:type)
242 242
       expect(response).to render_template("edit")
243 243
     end
244 244
 
245 245
     it "updates attributes on Agents for the current user" do
246 246
       sign_in users(:bob)
247
-      post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name")
247
+      post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name")}
248 248
       expect(response).to redirect_to(agents_path)
249 249
       expect(agents(:bob_website_agent).reload.name).to eq("New name")
250 250
 
251 251
       expect {
252
-        post :update, :id => agents(:jane_website_agent).to_param, :agent => valid_attributes(:name => "New name")
252
+        post :update, params: {:id => agents(:jane_website_agent).to_param, :agent => valid_attributes(:name => "New name")}
253 253
       }.to raise_error(ActiveRecord::RecordNotFound)
254 254
     end
255 255
 
256 256
     it "accepts JSON requests" do
257 257
       sign_in users(:bob)
258
-      post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :format => :json
258
+      post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name")}, :format => :json
259 259
       expect(agents(:bob_website_agent).reload.name).to eq("New name")
260 260
       expect(JSON.parse(response.body)['name']).to eq("New name")
261 261
       expect(response).to be_success
@@ -263,19 +263,19 @@ describe AgentsController do
263 263
 
264 264
     it "will not accept Agent sources owned by other users" do
265 265
       sign_in users(:bob)
266
-      post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:source_ids => [agents(:jane_weather_agent).id])
266
+      post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:source_ids => [agents(:jane_weather_agent).id])}
267 267
       expect(assigns(:agent)).to have(1).errors_on(:sources)
268 268
     end
269 269
 
270 270
     it "will not accept Scenarios owned by other users" do
271 271
       sign_in users(:bob)
272
-      post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:scenario_ids => [scenarios(:jane_weather).id])
272
+      post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:scenario_ids => [scenarios(:jane_weather).id])}
273 273
       expect(assigns(:agent)).to have(1).errors_on(:scenarios)
274 274
     end
275 275
 
276 276
     it "shows errors" do
277 277
       sign_in users(:bob)
278
-      post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "")
278
+      post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "")}
279 279
       expect(assigns(:agent)).to have(1).errors_on(:name)
280 280
       expect(response).to render_template("edit")
281 281
     end
@@ -283,7 +283,7 @@ describe AgentsController do
283 283
     it 'does not allow to modify the agents user_id' do
284 284
       sign_in users(:bob)
285 285
       expect {
286
-        post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:user_id => users(:jane).id)
286
+        post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:user_id => users(:jane).id)}
287 287
       }.to raise_error(ActionController::UnpermittedParameters)
288 288
     end
289 289
 
@@ -293,28 +293,28 @@ describe AgentsController do
293 293
       end
294 294
 
295 295
       it "can redirect back to the show path" do
296
-        post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "show"
296
+        post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "show"}
297 297
         expect(response).to redirect_to(agent_path(agents(:bob_website_agent)))
298 298
       end
299 299
 
300 300
       it "redirect back to the index path by default" do
301
-        post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name")
301
+        post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name")}
302 302
         expect(response).to redirect_to(agents_path)
303 303
       end
304 304
 
305 305
       it "accepts return paths to scenarios" do
306
-        post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "/scenarios/2"
306
+        post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "/scenarios/2"}
307 307
         expect(response).to redirect_to("/scenarios/2")
308 308
       end
309 309
 
310 310
       it "sanitizes return paths" do
311
-        post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "/scenar"
311
+        post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "/scenar"}
312 312
         expect(response).to redirect_to(agents_path)
313 313
 
314
-        post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "http://google.com"
314
+        post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "http://google.com"}
315 315
         expect(response).to redirect_to(agents_path)
316 316
 
317
-        post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "javascript:alert(1)"
317
+        post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "javascript:alert(1)"}
318 318
         expect(response).to redirect_to(agents_path)
319 319
       end
320 320
     end
@@ -325,7 +325,7 @@ describe AgentsController do
325 325
       agent.disabled = true
326 326
       agent.last_checked_event_id = nil
327 327
       agent.save!
328
-      post :update, id: agents(:bob_website_agent).to_param, agent: { disabled: 'false', drop_pending_events: 'true' }
328
+      post :update, params: {id: agents(:bob_website_agent).to_param, agent: { disabled: 'false', drop_pending_events: 'true' }}
329 329
       agent.reload
330 330
       expect(agent.disabled).to eq(false)
331 331
       expect(agent.last_checked_event_id).to eq(Event.maximum(:id))
@@ -337,13 +337,13 @@ describe AgentsController do
337 337
       sign_in users(:bob)
338 338
 
339 339
       expect(agents(:bob_weather_agent).scenarios).to include(scenarios(:bob_weather))
340
-      put :leave_scenario, :id => agents(:bob_weather_agent).to_param, :scenario_id => scenarios(:bob_weather).to_param
340
+      put :leave_scenario, params: {:id => agents(:bob_weather_agent).to_param, :scenario_id => scenarios(:bob_weather).to_param}
341 341
       expect(agents(:bob_weather_agent).scenarios).not_to include(scenarios(:bob_weather))
342 342
 
343 343
       expect(Scenario.where(:id => scenarios(:bob_weather).id)).to exist
344 344
 
345 345
       expect {
346
-        put :leave_scenario, :id => agents(:jane_weather_agent).to_param, :scenario_id => scenarios(:jane_weather).to_param
346
+        put :leave_scenario, params: {:id => agents(:jane_weather_agent).to_param, :scenario_id => scenarios(:jane_weather).to_param}
347 347
       }.to raise_error(ActiveRecord::RecordNotFound)
348 348
     end
349 349
   end
@@ -352,25 +352,25 @@ describe AgentsController do
352 352
     it "destroys only Agents owned by the current user" do
353 353
       sign_in users(:bob)
354 354
       expect {
355
-        delete :destroy, :id => agents(:bob_website_agent).to_param
355
+        delete :destroy, params: {:id => agents(:bob_website_agent).to_param}
356 356
       }.to change(Agent, :count).by(-1)
357 357
 
358 358
       expect {
359
-        delete :destroy, :id => agents(:jane_website_agent).to_param
359
+        delete :destroy, params: {:id => agents(:jane_website_agent).to_param}
360 360
       }.to raise_error(ActiveRecord::RecordNotFound)
361 361
     end
362 362
 
363 363
     it "redirects correctly when the Agent is deleted from the Agent itself" do
364 364
       sign_in users(:bob)
365 365
 
366
-      delete :destroy, :id => agents(:bob_website_agent).to_param
366
+      delete :destroy, params: {:id => agents(:bob_website_agent).to_param}
367 367
       expect(response).to redirect_to agents_path
368 368
     end
369 369
 
370 370
     it "redirects correctly when the Agent is deleted from a Scenario" do
371 371
       sign_in users(:bob)
372 372
 
373
-      delete :destroy, :id => agents(:bob_weather_agent).to_param, :return => scenario_path(scenarios(:bob_weather)).to_param
373
+      delete :destroy, params: {:id => agents(:bob_weather_agent).to_param, :return => scenario_path(scenarios(:bob_weather)).to_param}
374 374
       expect(response).to redirect_to scenario_path(scenarios(:bob_weather))
375 375
     end
376 376
   end
@@ -387,7 +387,7 @@ describe AgentsController do
387 387
           stub(klass).validate_option { true }
388 388
         end
389 389
 
390
-        post :validate, @params
390
+        post :validate, params: @params
391 391
         expect(response.status).to eq 200
392 392
       end
393 393
 
@@ -396,7 +396,7 @@ describe AgentsController do
396 396
           stub(klass).validate_option { false }
397 397
         end
398 398
 
399
-        post :validate, @params
399
+        post :validate, params: @params
400 400
         expect(response.status).to eq 403
401 401
       end
402 402
     end
@@ -407,7 +407,7 @@ describe AgentsController do
407 407
           stub(klass).complete_option { [{name: 'test', value: 1}] }
408 408
         end
409 409
 
410
-        post :complete, @params
410
+        post :complete, params: @params
411 411
         expect(response.status).to eq 200
412 412
         expect(response.header['Content-Type']).to include('application/json')
413 413
 
@@ -420,7 +420,7 @@ describe AgentsController do
420 420
       agent = agents(:bob_website_agent)
421 421
       agent.update!(memory: { "test" => 42 })
422 422
       sign_in users(:bob)
423
-      delete :destroy_memory, id: agent.to_param
423
+      delete :destroy_memory, params: {id: agent.to_param}
424 424
       expect(agent.reload.memory).to eq({})
425 425
     end
426 426
 
@@ -429,7 +429,7 @@ describe AgentsController do
429 429
       agent.update!(memory: { "test" => 42 })
430 430
       sign_in users(:bob)
431 431
       expect {
432
-        delete :destroy_memory, id: agent.to_param
432
+        delete :destroy_memory, params: {id: agent.to_param}
433 433
       }.to raise_error(ActiveRecord::RecordNotFound)
434 434
       expect(agent.reload.memory).to eq({ "test" => 42})
435 435
     end

+ 8 - 8
spec/controllers/events_controller_spec.rb

@@ -15,12 +15,12 @@ describe EventsController do
15 15
 
16 16
     it "can filter by Agent" do
17 17
       sign_in users(:bob)
18
-      get :index, :agent_id => agents(:bob_website_agent)
18
+      get :index, params: {:agent_id => agents(:bob_website_agent)}
19 19
       expect(assigns(:events).length).to eq(agents(:bob_website_agent).events.length)
20 20
       expect(assigns(:events).all? {|i| expect(i.agent).to eq(agents(:bob_website_agent)) }).to be_truthy
21 21
 
22 22
       expect {
23
-        get :index, :agent_id => agents(:jane_website_agent)
23
+        get :index, params: {:agent_id => agents(:jane_website_agent)}
24 24
       }.to raise_error(ActiveRecord::RecordNotFound)
25 25
     end
26 26
   end
@@ -28,11 +28,11 @@ describe EventsController do
28 28
   describe "GET show" do
29 29
     it "only shows Events for the current user" do
30 30
       sign_in users(:bob)
31
-      get :show, :id => events(:bob_website_agent_event).to_param
31
+      get :show, params: {:id => events(:bob_website_agent_event).to_param}
32 32
       expect(assigns(:event)).to eq(events(:bob_website_agent_event))
33 33
 
34 34
       expect {
35
-        get :show, :id => events(:jane_website_agent_event).to_param
35
+        get :show, params: {:id => events(:jane_website_agent_event).to_param}
36 36
       }.to raise_error(ActiveRecord::RecordNotFound)
37 37
     end
38 38
   end
@@ -45,7 +45,7 @@ describe EventsController do
45 45
 
46 46
     it "clones and re-emits events" do
47 47
       expect {
48
-        post :reemit, :id => events(:bob_website_agent_event).to_param
48
+        post :reemit, params: {:id => events(:bob_website_agent_event).to_param}
49 49
       }.to change { Event.count }.by(1)
50 50
       expect(Event.last.payload).to eq(events(:bob_website_agent_event).payload)
51 51
       expect(Event.last.agent).to eq(events(:bob_website_agent_event).agent)
@@ -54,7 +54,7 @@ describe EventsController do
54 54
 
55 55
     it "can only re-emit Events for the current user" do
56 56
       expect {
57
-        post :reemit, :id => events(:jane_website_agent_event).to_param
57
+        post :reemit, params: {:id => events(:jane_website_agent_event).to_param}
58 58
       }.to raise_error(ActiveRecord::RecordNotFound)
59 59
     end
60 60
   end
@@ -63,11 +63,11 @@ describe EventsController do
63 63
     it "only deletes events for the current user" do
64 64
       sign_in users(:bob)
65 65
       expect {
66
-        delete :destroy, :id => events(:bob_website_agent_event).to_param
66
+        delete :destroy, params: {:id => events(:bob_website_agent_event).to_param}
67 67
       }.to change { Event.count }.by(-1)
68 68
 
69 69
       expect {
70
-        delete :destroy, :id => events(:jane_website_agent_event).to_param
70
+        delete :destroy, params: {:id => events(:jane_website_agent_event).to_param}
71 71
       }.to raise_error(ActiveRecord::RecordNotFound)
72 72
     end
73 73
   end

+ 5 - 5
spec/controllers/jobs_controller_spec.rb

@@ -37,11 +37,11 @@ describe JobsController do
37 37
     end
38 38
 
39 39
     it "destroy a job which is not running" do
40
-      expect { delete :destroy, id: @not_running.id }.to change(Delayed::Job, :count).by(-1)
40
+      expect { delete :destroy, params: {id: @not_running.id} }.to change(Delayed::Job, :count).by(-1)
41 41
     end
42 42
 
43 43
     it "does not destroy a running job" do
44
-      expect { delete :destroy, id: @running.id }.to change(Delayed::Job, :count).by(0)
44
+      expect { delete :destroy, params: {id: @running.id} }.to change(Delayed::Job, :count).by(0)
45 45
     end
46 46
   end
47 47
 
@@ -54,15 +54,15 @@ describe JobsController do
54 54
     end
55 55
 
56 56
     it "queue a job which is not running" do
57
-      expect { put :run, id: @not_running.id }.to change { @not_running.reload.run_at }
57
+      expect { put :run, params: {id: @not_running.id} }.to change { @not_running.reload.run_at }
58 58
     end
59 59
 
60 60
     it "queue a job that failed" do
61
-      expect { put :run, id: @failed.id }.to change { @failed.reload.run_at }
61
+      expect { put :run, params: {id: @failed.id} }.to change { @failed.reload.run_at }
62 62
     end
63 63
 
64 64
     it "not queue a running job" do
65
-      expect { put :run, id: @running.id }.not_to change { @not_running.reload.run_at }
65
+      expect { put :run, params: {id: @running.id} }.not_to change { @not_running.reload.run_at }
66 66
     end
67 67
   end
68 68
 

+ 4 - 4
spec/controllers/logs_controller_spec.rb

@@ -4,7 +4,7 @@ describe LogsController do
4 4
   describe "GET index" do
5 5
     it "can filter by Agent" do
6 6
       sign_in users(:bob)
7
-      get :index, :agent_id => agents(:bob_weather_agent).id
7
+      get :index, params: {:agent_id => agents(:bob_weather_agent).id}
8 8
       expect(assigns(:logs).length).to eq(agents(:bob_weather_agent).logs.length)
9 9
       expect(assigns(:logs).all? {|i| expect(i.agent).to eq(agents(:bob_weather_agent)) }).to be_truthy
10 10
     end
@@ -12,7 +12,7 @@ describe LogsController do
12 12
     it "only loads Agents owned by the current user" do
13 13
       sign_in users(:bob)
14 14
       expect {
15
-        get :index, :agent_id => agents(:jane_weather_agent).id
15
+        get :index, params: {:agent_id => agents(:jane_weather_agent).id}
16 16
       }.to raise_error(ActiveRecord::RecordNotFound)
17 17
     end
18 18
   end
@@ -22,7 +22,7 @@ describe LogsController do
22 22
       agents(:bob_weather_agent).last_error_log_at = 2.hours.ago
23 23
       sign_in users(:bob)
24 24
       expect {
25
-        delete :clear, :agent_id => agents(:bob_weather_agent).id
25
+        delete :clear, params: {:agent_id => agents(:bob_weather_agent).id}
26 26
       }.to change { AgentLog.count }.by(-1 * agents(:bob_weather_agent).logs.count)
27 27
       expect(assigns(:logs).length).to eq(0)
28 28
       expect(agents(:bob_weather_agent).reload.logs.count).to eq(0)
@@ -32,7 +32,7 @@ describe LogsController do
32 32
     it "only deletes logs for an Agent owned by the current user" do
33 33
       sign_in users(:bob)
34 34
       expect {
35
-        delete :clear, :agent_id => agents(:jane_weather_agent).id
35
+        delete :clear, params: {:agent_id => agents(:jane_weather_agent).id}
36 36
       }.to raise_error(ActiveRecord::RecordNotFound)
37 37
     end
38 38
   end

+ 1 - 1
spec/controllers/scenario_imports_controller_spec.rb

@@ -15,7 +15,7 @@ describe ScenarioImportsController do
15 15
 
16 16
   describe "POST create" do
17 17
     it "initializes a ScenarioImport for current_user, passing in params" do
18
-      post :create, :scenario_import => { :url => "bad url" }
18
+      post :create, params: {:scenario_import => { :url => "bad url" }}
19 19
       expect(assigns(:scenario_import).user).to eq(users(:bob))
20 20
       expect(assigns(:scenario_import).url).to eq("bad url")
21 21
       expect(assigns(:scenario_import)).not_to be_valid

+ 23 - 23
spec/controllers/scenarios_controller_spec.rb

@@ -18,34 +18,34 @@ describe ScenariosController do
18 18
 
19 19
   describe "GET show" do
20 20
     it "only shows Scenarios for the current user" do
21
-      get :show, :id => scenarios(:bob_weather).to_param
21
+      get :show, params: {:id => scenarios(:bob_weather).to_param}
22 22
       expect(assigns(:scenario)).to eq(scenarios(:bob_weather))
23 23
 
24 24
       expect {
25
-        get :show, :id => scenarios(:jane_weather).to_param
25
+        get :show, params: {:id => scenarios(:jane_weather).to_param}
26 26
       }.to raise_error(ActiveRecord::RecordNotFound)
27 27
     end
28 28
 
29 29
     it "loads Agents for the requested Scenario" do
30
-      get :show, :id => scenarios(:bob_weather).to_param
30
+      get :show, params: {:id => scenarios(:bob_weather).to_param}
31 31
       expect(assigns(:agents).pluck(:id).sort).to eq(scenarios(:bob_weather).agents.pluck(:id).sort)
32 32
     end
33 33
   end
34 34
 
35 35
   describe "GET share" do
36 36
     it "only displays Scenario share information for the current user" do
37
-      get :share, :id => scenarios(:bob_weather).to_param
37
+      get :share, params: {:id => scenarios(:bob_weather).to_param}
38 38
       expect(assigns(:scenario)).to eq(scenarios(:bob_weather))
39 39
 
40 40
       expect {
41
-        get :share, :id => scenarios(:jane_weather).to_param
41
+        get :share, params: {:id => scenarios(:jane_weather).to_param}
42 42
       }.to raise_error(ActiveRecord::RecordNotFound)
43 43
     end
44 44
   end
45 45
 
46 46
   describe "GET export" do
47 47
     it "returns a JSON file download from an instantiated AgentsExporter" do
48
-      get :export, :id => scenarios(:bob_weather).to_param
48
+      get :export, params: {:id => scenarios(:bob_weather).to_param}
49 49
       expect(assigns(:exporter).options[:name]).to eq(scenarios(:bob_weather).name)
50 50
       expect(assigns(:exporter).options[:description]).to eq(scenarios(:bob_weather).description)
51 51
       expect(assigns(:exporter).options[:agents]).to eq(scenarios(:bob_weather).agents)
@@ -59,11 +59,11 @@ describe ScenariosController do
59 59
     end
60 60
 
61 61
     it "only exports private Scenarios for the current user" do
62
-      get :export, :id => scenarios(:bob_weather).to_param
62
+      get :export, params: {:id => scenarios(:bob_weather).to_param}
63 63
       expect(assigns(:scenario)).to eq(scenarios(:bob_weather))
64 64
 
65 65
       expect {
66
-        get :export, :id => scenarios(:jane_weather).to_param
66
+        get :export, params: {:id => scenarios(:jane_weather).to_param}
67 67
       }.to raise_error(ActiveRecord::RecordNotFound)
68 68
     end
69 69
 
@@ -73,14 +73,14 @@ describe ScenariosController do
73 73
       end
74 74
 
75 75
       it "exports public scenarios for other users when logged in" do
76
-        get :export, :id => scenarios(:jane_weather).to_param
76
+        get :export, params: {:id => scenarios(:jane_weather).to_param}
77 77
         expect(assigns(:scenario)).to eq(scenarios(:jane_weather))
78 78
         expect(assigns(:exporter).options[:source_url]).to eq(export_scenario_url(scenarios(:jane_weather)))
79 79
       end
80 80
 
81 81
       it "exports public scenarios for other users when logged out" do
82 82
         sign_out :user
83
-        get :export, :id => scenarios(:jane_weather).to_param
83
+        get :export, params: {:id => scenarios(:jane_weather).to_param}
84 84
         expect(assigns(:scenario)).to eq(scenarios(:jane_weather))
85 85
         expect(assigns(:exporter).options[:source_url]).to eq(export_scenario_url(scenarios(:jane_weather)))
86 86
       end
@@ -89,11 +89,11 @@ describe ScenariosController do
89 89
 
90 90
   describe "GET edit" do
91 91
     it "only shows Scenarios for the current user" do
92
-      get :edit, :id => scenarios(:bob_weather).to_param
92
+      get :edit, params: {:id => scenarios(:bob_weather).to_param}
93 93
       expect(assigns(:scenario)).to eq(scenarios(:bob_weather))
94 94
 
95 95
       expect {
96
-        get :edit, :id => scenarios(:jane_weather).to_param
96
+        get :edit, params: {:id => scenarios(:jane_weather).to_param}
97 97
       }.to raise_error(ActiveRecord::RecordNotFound)
98 98
     end
99 99
   end
@@ -101,13 +101,13 @@ describe ScenariosController do
101 101
   describe "POST create" do
102 102
     it "creates Scenarios for the current user" do
103 103
       expect {
104
-        post :create, :scenario => valid_attributes
104
+        post :create, params: {:scenario => valid_attributes}
105 105
       }.to change { users(:bob).scenarios.count }.by(1)
106 106
     end
107 107
 
108 108
     it "shows errors" do
109 109
       expect {
110
-        post :create, :scenario => valid_attributes(:name => "")
110
+        post :create, params: {:scenario => valid_attributes(:name => "")}
111 111
       }.not_to change { users(:bob).scenarios.count }
112 112
       expect(assigns(:scenario)).to have(1).errors_on(:name)
113 113
       expect(response).to render_template("new")
@@ -115,33 +115,33 @@ describe ScenariosController do
115 115
 
116 116
     it "will not create Scenarios for other users" do
117 117
       expect {
118
-        post :create, :scenario => valid_attributes(:user_id => users(:jane).id)
118
+        post :create, params: {:scenario => valid_attributes(:user_id => users(:jane).id)}
119 119
       }.to raise_error(ActionController::UnpermittedParameters)
120 120
     end
121 121
   end
122 122
 
123 123
   describe "PUT update" do
124 124
     it "updates attributes on Scenarios for the current user" do
125
-      post :update, :id => scenarios(:bob_weather).to_param, :scenario => { :name => "new_name", :public => "1" }
125
+      post :update, params: {:id => scenarios(:bob_weather).to_param, :scenario => { :name => "new_name", :public => "1" }}
126 126
       expect(response).to redirect_to(scenario_path(scenarios(:bob_weather)))
127 127
       expect(scenarios(:bob_weather).reload.name).to eq("new_name")
128 128
       expect(scenarios(:bob_weather)).to be_public
129 129
 
130 130
       expect {
131
-        post :update, :id => scenarios(:jane_weather).to_param, :scenario => { :name => "new_name" }
131
+        post :update, params: {:id => scenarios(:jane_weather).to_param, :scenario => { :name => "new_name" }}
132 132
       }.to raise_error(ActiveRecord::RecordNotFound)
133 133
       expect(scenarios(:jane_weather).reload.name).not_to eq("new_name")
134 134
     end
135 135
 
136 136
     it "shows errors" do
137
-      post :update, :id => scenarios(:bob_weather).to_param, :scenario => { :name => "" }
137
+      post :update, params: {:id => scenarios(:bob_weather).to_param, :scenario => { :name => "" }}
138 138
       expect(assigns(:scenario)).to have(1).errors_on(:name)
139 139
       expect(response).to render_template("edit")
140 140
     end
141 141
 
142 142
     it 'adds an agent to the scenario' do
143 143
       expect {
144
-        post :update, :id => scenarios(:bob_weather).to_param, :scenario => { :name => "new_name", :public => "1", agent_ids: scenarios(:bob_weather).agent_ids + [agents(:bob_website_agent).id] }
144
+        post :update, params: {:id => scenarios(:bob_weather).to_param, :scenario => { :name => "new_name", :public => "1", agent_ids: scenarios(:bob_weather).agent_ids + [agents(:bob_website_agent).id] }}
145 145
       }.to change { scenarios(:bob_weather).agent_ids.length }.by(1)
146 146
     end
147 147
   end
@@ -149,7 +149,7 @@ describe ScenariosController do
149 149
   describe 'PUT enable_or_disable_all_agents' do
150 150
     it 'updates disabled on all agents in a scenario for the current user' do
151 151
       @params = {"scenario"=>{"disabled"=>"true"}, "commit"=>"Yes", "id"=> scenarios(:bob_weather).id}
152
-      put :enable_or_disable_all_agents, @params
152
+      put :enable_or_disable_all_agents, params: @params
153 153
       expect(agents(:bob_rain_notifier_agent).disabled).to eq(true)
154 154
       expect(response).to redirect_to(scenario_path(scenarios(:bob_weather)))
155 155
     end
@@ -158,17 +158,17 @@ describe ScenariosController do
158 158
   describe "DELETE destroy" do
159 159
     it "destroys only Scenarios owned by the current user" do
160 160
       expect {
161
-        delete :destroy, :id => scenarios(:bob_weather).to_param
161
+        delete :destroy, params: {:id => scenarios(:bob_weather).to_param}
162 162
       }.to change(Scenario, :count).by(-1)
163 163
 
164 164
       expect {
165
-        delete :destroy, :id => scenarios(:jane_weather).to_param
165
+        delete :destroy, params: {:id => scenarios(:jane_weather).to_param}
166 166
       }.to raise_error(ActiveRecord::RecordNotFound)
167 167
     end
168 168
 
169 169
     it "passes the mode to the model" do
170 170
       expect {
171
-        delete :destroy, id: scenarios(:bob_weather).to_param, mode: 'all_agents'
171
+        delete :destroy, params: {id: scenarios(:bob_weather).to_param, mode: 'all_agents'}
172 172
       }.to change(Agent, :count).by(-2)
173 173
     end
174 174
   end

+ 4 - 4
spec/controllers/services_controller_spec.rb

@@ -14,14 +14,14 @@ describe ServicesController do
14 14
 
15 15
   describe "POST toggle_availability" do
16 16
     it "should work for service of the user" do
17
-      post :toggle_availability, :id => services(:generic).to_param
17
+      post :toggle_availability, params: {:id => services(:generic).to_param}
18 18
       expect(assigns(:service)).to eq(services(:generic))
19 19
       redirect_to(services_path)
20 20
     end
21 21
 
22 22
     it "should not work for a service of another user" do
23 23
       expect {
24
-        post :toggle_availability, :id => services(:global).to_param
24
+        post :toggle_availability, params: {:id => services(:global).to_param}
25 25
       }.to raise_error(ActiveRecord::RecordNotFound)
26 26
     end
27 27
   end
@@ -29,11 +29,11 @@ describe ServicesController do
29 29
   describe "DELETE destroy" do
30 30
     it "destroys only services owned by the current user" do
31 31
       expect {
32
-        delete :destroy, :id => services(:generic).to_param
32
+        delete :destroy, params: {:id => services(:generic).to_param}
33 33
       }.to change(Service, :count).by(-1)
34 34
 
35 35
       expect {
36
-        delete :destroy, :id => services(:global).to_param
36
+        delete :destroy, params: {:id => services(:global).to_param}
37 37
       }.to raise_error(ActiveRecord::RecordNotFound)
38 38
     end
39 39
   end

+ 13 - 13
spec/controllers/user_credentials_controller_spec.rb

@@ -22,30 +22,30 @@ describe UserCredentialsController do
22 22
 
23 23
   describe "GET edit" do
24 24
     it "only shows UserCredentials for the current user" do
25
-      get :edit, :id => user_credentials(:bob_aws_secret).to_param
25
+      get :edit, params: {:id => user_credentials(:bob_aws_secret).to_param}
26 26
       expect(assigns(:user_credential)).to eq(user_credentials(:bob_aws_secret))
27 27
 
28 28
       expect {
29
-        get :edit, :id => user_credentials(:jane_aws_secret).to_param
29
+        get :edit, params: {:id => user_credentials(:jane_aws_secret).to_param}
30 30
       }.to raise_error(ActiveRecord::RecordNotFound)
31 31
     end
32 32
   end
33 33
 
34 34
   describe "Post import" do
35 35
     it "asserts user credentials were created for current user only" do
36
-      post :import, :file => @file
36
+      post :import, params: {:file => @file}
37 37
       expect(controller.current_user.id).to eq(users(:bob).id)
38 38
       expect(controller.current_user.user_credentials).to eq(users(:bob).user_credentials)
39 39
     end
40 40
 
41 41
     it "asserts that primary id in json file is ignored" do
42
-      post :import, :file => @file
42
+      post :import, params: {:file => @file}
43 43
       expect(controller.current_user.user_credentials.last.id).not_to eq(24)
44 44
     end
45 45
 
46 46
     it "duplicate credential name shows an error that it is not saved" do
47 47
       file1 = fixture_file_upload('multiple_user_credentials.json')
48
-      post :import, :file => file1
48
+      post :import, params: {:file => file1}
49 49
       expect(flash[:notice]).to eq("One or more of the uploaded credentials was not imported due to an error. Perhaps an existing credential had the same name?")
50 50
       expect(response).to redirect_to(user_credentials_path)
51 51
     end
@@ -54,13 +54,13 @@ describe UserCredentialsController do
54 54
   describe "POST create" do
55 55
     it "creates UserCredentials for the current user" do
56 56
       expect {
57
-        post :create, :user_credential => valid_attributes
57
+        post :create, params: {:user_credential => valid_attributes}
58 58
       }.to change { users(:bob).user_credentials.count }.by(1)
59 59
     end
60 60
 
61 61
     it "shows errors" do
62 62
       expect {
63
-        post :create, :user_credential => valid_attributes(:credential_name => "")
63
+        post :create, params: {:user_credential => valid_attributes(:credential_name => "")}
64 64
       }.not_to change { users(:bob).user_credentials.count }
65 65
       expect(assigns(:user_credential)).to have(1).errors_on(:credential_name)
66 66
       expect(response).to render_template("new")
@@ -68,25 +68,25 @@ describe UserCredentialsController do
68 68
 
69 69
     it "will not create UserCredentials for other users" do
70 70
       expect {
71
-        post :create, :user_credential => valid_attributes(:user_id => users(:jane).id)
71
+        post :create, params: {:user_credential => valid_attributes(:user_id => users(:jane).id)}
72 72
       }.to raise_error(ActionController::UnpermittedParameters)
73 73
     end
74 74
   end
75 75
 
76 76
   describe "PUT update" do
77 77
     it "updates attributes on UserCredentials for the current user" do
78
-      post :update, :id => user_credentials(:bob_aws_key).to_param, :user_credential => { :credential_name => "new_name" }
78
+      post :update, params: {:id => user_credentials(:bob_aws_key).to_param, :user_credential => { :credential_name => "new_name" }}
79 79
       expect(response).to redirect_to(user_credentials_path)
80 80
       expect(user_credentials(:bob_aws_key).reload.credential_name).to eq("new_name")
81 81
 
82 82
       expect {
83
-        post :update, :id => user_credentials(:jane_aws_key).to_param, :user_credential => { :credential_name => "new_name" }
83
+        post :update, params: {:id => user_credentials(:jane_aws_key).to_param, :user_credential => { :credential_name => "new_name" }}
84 84
       }.to raise_error(ActiveRecord::RecordNotFound)
85 85
       expect(user_credentials(:jane_aws_key).reload.credential_name).not_to eq("new_name")
86 86
     end
87 87
 
88 88
     it "shows errors" do
89
-      post :update, :id => user_credentials(:bob_aws_key).to_param, :user_credential => { :credential_name => "" }
89
+      post :update, params: {:id => user_credentials(:bob_aws_key).to_param, :user_credential => { :credential_name => "" }}
90 90
       expect(assigns(:user_credential)).to have(1).errors_on(:credential_name)
91 91
       expect(response).to render_template("edit")
92 92
     end
@@ -95,11 +95,11 @@ describe UserCredentialsController do
95 95
   describe "DELETE destroy" do
96 96
     it "destroys only UserCredentials owned by the current user" do
97 97
       expect {
98
-        delete :destroy, :id => user_credentials(:bob_aws_key).to_param
98
+        delete :destroy, params: {:id => user_credentials(:bob_aws_key).to_param}
99 99
       }.to change(UserCredential, :count).by(-1)
100 100
 
101 101
       expect {
102
-        delete :destroy, :id => user_credentials(:jane_aws_key).to_param
102
+        delete :destroy, params: {:id => user_credentials(:jane_aws_key).to_param}
103 103
       }.to raise_error(ActiveRecord::RecordNotFound)
104 104
     end
105 105
   end

+ 6 - 6
spec/controllers/users/registrations_controller_spec.rb

@@ -2,8 +2,6 @@ require 'rails_helper'
2 2
 
3 3
 module Users
4 4
   describe RegistrationsController do
5
-    include Devise::TestHelpers
6
-
7 5
     describe "POST create" do
8 6
       before do
9 7
         @request.env["devise.mapping"] = Devise.mappings[:user]
@@ -13,8 +11,10 @@ module Users
13 11
         it "imports the default scenario for the new user" do
14 12
           mock(DefaultScenarioImporter).import(is_a(User))
15 13
 
16
-          post :create, :user => {username: 'jdoe', email: 'jdoe@example.com',
17
-            password: 's3cr3t55', password_confirmation: 's3cr3t55', invitation_code: 'try-huginn'}
14
+          post :create, params: {
15
+            :user => {username: 'jdoe', email: 'jdoe@example.com',
16
+              password: 's3cr3t55', password_confirmation: 's3cr3t55', invitation_code: 'try-huginn'}
17
+          }
18 18
         end
19 19
       end
20 20
 
@@ -23,11 +23,11 @@ module Users
23 23
           stub(DefaultScenarioImporter).import(is_a(User)) { fail "Should not attempt import" }
24 24
 
25 25
           setup_controller_for_warden
26
-          post :create, :user => {}
26
+          post :create, params: {:user => {}}
27 27
         end
28 28
 
29 29
         it 'does not allow to set the admin flag' do
30
-          expect { post :create, :user => {admin: 'true'} }.to raise_error(ActionController::UnpermittedParameters)
30
+          expect { post :create, params: {:user => {admin: 'true'}} }.to raise_error(ActionController::UnpermittedParameters)
31 31
         end
32 32
       end
33 33
     end

+ 14 - 14
spec/controllers/web_requests_controller_spec.rb

@@ -26,14 +26,14 @@ describe WebRequestsController do
26 26
 
27 27
   it "should not require login to receive a web request" do
28 28
     expect(@agent.last_web_request_at).to be_nil
29
-    post :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"
29
+    post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}
30 30
     expect(@agent.reload.last_web_request_at).to be_within(2).of(Time.now)
31 31
     expect(response.body).to eq("success")
32 32
     expect(response).to be_success
33 33
   end
34 34
 
35 35
   it "should call receive_web_request" do
36
-    post :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"
36
+    post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}
37 37
     @agent.reload
38 38
     expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" })
39 39
     expect(@agent.memory[:web_request_format]).to eq("text/html")
@@ -42,14 +42,14 @@ describe WebRequestsController do
42 42
     expect(response.headers['Content-Type']).to eq('text/plain; charset=utf-8')
43 43
     expect(response).to be_success
44 44
 
45
-    post :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "not_my_secret", :no => "go"
45
+    post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "not_my_secret", :no => "go"}
46 46
     expect(@agent.reload.memory[:web_request_values]).not_to eq({ 'no' => "go" })
47 47
     expect(response.body).to eq("failure")
48 48
     expect(response).to be_missing
49 49
   end
50 50
 
51 51
   it "should accept gets" do
52
-    get :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"
52
+    get :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}
53 53
     @agent.reload
54 54
     expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" })
55 55
     expect(@agent.memory[:web_request_format]).to eq("text/html")
@@ -59,19 +59,19 @@ describe WebRequestsController do
59 59
   end
60 60
 
61 61
   it "should pass through the received format" do
62
-    get :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5", :format => :json
62
+    get :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}, :format => :json
63 63
     @agent.reload
64 64
     expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" })
65 65
     expect(@agent.memory[:web_request_format]).to eq("application/json")
66 66
     expect(@agent.memory[:web_request_method]).to eq("get")
67 67
 
68
-    post :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5", :format => :xml
68
+    post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}, :format => :xml
69 69
     @agent.reload
70 70
     expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" })
71 71
     expect(@agent.memory[:web_request_format]).to eq("application/xml")
72 72
     expect(@agent.memory[:web_request_method]).to eq("post")
73 73
 
74
-    put :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5", :format => :atom
74
+    put :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}, :format => :atom
75 75
     @agent.reload
76 76
     expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" })
77 77
     expect(@agent.memory[:web_request_format]).to eq("application/atom+xml")
@@ -81,17 +81,17 @@ describe WebRequestsController do
81 81
   it "can accept a content-type to return" do
82 82
     @agent.memory['content_type'] = 'application/json'
83 83
     @agent.save!
84
-    get :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"
84
+    get :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}
85 85
     expect(response.headers['Content-Type']).to eq('application/json; charset=utf-8')
86 86
   end
87 87
 
88 88
   it "should fail on incorrect users" do
89
-    post :handle_request, :user_id => users(:jane).to_param, :agent_id => @agent.id, :secret => "my_secret", :no => "go"
89
+    post :handle_request, params: {:user_id => users(:jane).to_param, :agent_id => @agent.id, :secret => "my_secret", :no => "go"}
90 90
     expect(response).to be_missing
91 91
   end
92 92
 
93 93
   it "should fail on incorrect agents" do
94
-    post :handle_request, :user_id => users(:bob).to_param, :agent_id => 454545, :secret => "my_secret", :no => "go"
94
+    post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => 454545, :secret => "my_secret", :no => "go"}
95 95
     expect(response).to be_missing
96 96
   end
97 97
 
@@ -102,7 +102,7 @@ describe WebRequestsController do
102 102
     end
103 103
 
104 104
     it "should create events without requiring login" do
105
-      post :update_location, user_id: users(:bob).to_param, secret: "my_secret", longitude: 123, latitude: 45, something: "else"
105
+      post :update_location, params: {user_id: users(:bob).to_param, secret: "my_secret", longitude: 123, latitude: 45, something: "else"}
106 106
       expect(@agent.events.last.payload).to eq({ 'longitude' => "123", 'latitude' => "45", 'something' => "else" })
107 107
       expect(@agent.events.last.lat).to eq(45)
108 108
       expect(@agent.events.last.lng).to eq(123)
@@ -112,13 +112,13 @@ describe WebRequestsController do
112 112
       @jane_agent = Agent.build_for_type("Agents::UserLocationAgent", users(:jane), name: "something", options: { secret: "my_secret" })
113 113
       @jane_agent.save!
114 114
 
115
-      post :update_location, user_id: users(:bob).to_param, secret: "my_secret", longitude: 123, latitude: 45, something: "else"
115
+      post :update_location, params: {user_id: users(:bob).to_param, secret: "my_secret", longitude: 123, latitude: 45, something: "else"}
116 116
       expect(@agent.events.last.payload).to eq({ 'longitude' => "123", 'latitude' => "45", 'something' => "else" })
117 117
       expect(@jane_agent.events).to be_empty
118 118
     end
119 119
 
120 120
     it "should raise a 404 error when given an invalid user id" do
121
-      post :update_location, user_id: "123", secret: "not_my_secret", longitude: 123, latitude: 45, something: "else"
121
+      post :update_location, params: {user_id: "123", secret: "not_my_secret", longitude: 123, latitude: 45, something: "else"}
122 122
       expect(response).to be_missing
123 123
     end
124 124
 
@@ -127,7 +127,7 @@ describe WebRequestsController do
127 127
       @agent2.save!
128 128
 
129 129
       expect {
130
-        post :update_location, user_id: users(:bob).to_param, secret: "my_secret2", longitude: 123, latitude: 45, something: "else"
130
+        post :update_location, params: {user_id: users(:bob).to_param, secret: "my_secret2", longitude: 123, latitude: 45, something: "else"}
131 131
         expect(@agent2.events.last.payload).to eq({ 'longitude' => "123", 'latitude' => "45", 'something' => "else" })
132 132
       }.not_to change { @agent.events.count }
133 133
     end